package vn.axonivy.vision.functionalinterface;

import java.util.function.Consumer;

public class Transaction {

	public static void main(String[] args) {
		Customer customer = new Customer();
		customer.setName("Tran Cuong Truc");
		customer.setBalance(5000);
		
		Transaction transaction = new Transaction();
		
		Consumer<Customer> consumer = c -> c.setBalance(c.getBalance() + 1000);
		transaction.updateBalance(customer, consumer);
	}
	
	public void updateBalance(Customer customer, Consumer<Customer> consumer) {
		System.out.println("Customer name: " + customer.getName());
		System.out.println("Before transaction: " + customer.getBalance());
		consumer.accept(customer);
		System.out.println("After transaction: " + customer.getBalance());
	}

}
